package com.z.controller;

import com.alibaba.fastjson.JSON;
import com.z.pojo.Type;
import com.z.service.impl.TypeServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * @author 张福兴
 * date 2021/9/1
 */
@WebServlet("/goodsType")
public class TypeServlet extends HttpServlet {

    private final TypeServiceImpl ts = new TypeServiceImpl();

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html;charset=UTF-8");
        List<Type> list = ts.allType();
        resp.getWriter().write(JSON.toJSONString(list));

    }
}
